﻿using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Data;
namespace WPFExcelReport
{
    public partial class TYGI09
    {
        public TYGI09()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_STOCKM ();
            this.DataContext = MV;
            InitializeComponent();
            
        }
        public void FilterMaster_Click(object sender, RoutedEventArgs e)
        {
            string filter = "ART LIKE '%" + txtART.Text.ToString().Trim() + "%' AND FARBE LIKE '" + txtFARBE.Text.Trim() + "%' AND ( SPPART LIKE '%" + txtSPPART.Text.ToString() + "%' OR FBPART LIKE '%" + txtSPPART.Text.ToString().Trim() + "%')";
            cvMaster.CustomFilter = filter;
        }

        public void FilterMasterClear_Click(object sender, RoutedEventArgs e)
        {

            cvMaster.CustomFilter = null;
        }
        public override void NewCommand(object sender, RoutedEventArgs e)
        {
            TMV.RefreshMGB(SYEAR + SMOTH, DTSTART, DTEND, LO, LB);
            base.NewCommand(sender, e);

        }

        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            TMV.LoadMStock(MDATE, DTSTART, DTEND, LO, LB);
            vwMaster.View.MoveCurrentToFirst();
            base.QueryCommand(sender, e);
        }
        public override void OnMKEYChg(DataRowView dwMKey)
        {
            if (dwMKey == null)
                return;
            string ART, VAR, FARBE, SPPART, ZWPART, FBPART, LO, LB, MDATE;
            DataTable tb;
            ART = dwMKey["ART"].ToString();
            VAR = dwMKey["VAR"].ToString();
            FARBE = dwMKey["FARBE"].ToString();
            LO = dwMKey["LO"].ToString();
            LB = dwMKey["LB"].ToString();
            SPPART = dwMKey["SPPART"].ToString();
            ZWPART = dwMKey["ZWPART"].ToString();
            FBPART = dwMKey["FBPART"].ToString();
            MDATE = dwMKey["MDATE"].ToString();
           string filter = "ART='" + ART + "' AND VAR='" + VAR + "' AND FARBE='" + FARBE + "' AND LO='" + LO + "' AND LB='" + LB + "' AND MDATE='" + MDATE + "'";
          
            if (vwMaster.View != null)
            {
                vwMaster.View.MoveCurrentToFirst();
            }
        }

        private void PrintCommand(object sender, RoutedEventArgs e)
        {

        }
       
    }
}
